﻿@{
    Layout = ViewBag.Layout;
}
@Styles.Render("~/Content/css")
<style>
    .wrap {
        min-height: initial;
        padding-bottom: 0px;
    }
    .top {
        height: 45px;
    }
    .disnone {
        display: none;
    }
    .welcome {
        float: right;
        padding: 0px;
    }
</style>
<script>
    $(function () {
        $("#UpdateSmiLink").click();
        ;
        //收藏，如果已经收藏则显示取消收藏
        var str = " <a onclick=\"showFavCate('" + $("#recTitle").val() + "')\" class='btn btn-m btn-prim-f ml10'><i class=\"iconfont icon-star\"></i>收藏</a>";
        if ($("#isFav").val() == 1) {
            str = "<a onclick=\"canclefav()\" class='btn btn-m btn-prim-f ml10'><i class=\"iconfont icon-star\"></i>取消收藏</a>";
        }
        $(".favCate").html(str);
    })
    //展示收藏列表
    function showFavCate(recordtitle) {
        $("#recTitle").val(recordtitle);
        favShow();
        //获取对应的数据
        $.ajax({
            type: "GET",
            url: timestamp("@Html.Raw(Url.Action("GetFavList", "UserCenter"))"),
            beforeSend: function () { $("#loading").show(); },
            success: function (msg) {
                var obj = eval(msg);
                $(".ulfield").empty();
                if (obj != null && obj.length > 0) {
                    for (var i = 0; i < obj.length; i++) {
                        var listr = " <li class=\"f-ct\" style=\"margin-left: 2em;\">  <label class=\"f-label block right\">" +
                       " <input type=\"radio\" name=\"favcate\" class=\"f-checkboxR\"  value='" + obj[i].FavoriteCategoryID + "' />" + obj[i].CategoryName + "</label></li>";
                        $(".ulfield").append(listr);
                    }
                    //默认第一个选中
                    $('input:radio:first').attr('checked', 'checked');
                }
                $("#loading").hide();
            },
            error: function (e)
            { $("#loading").hide(); }

        })
    }
    function favShow() {
        $(".message").show();
    }
    function favClose() {
        $(".message").hide();
    }
    //保存收藏
    function savefav() {
        var dbCode = $("#dbCode").val();
        var dbName = $("#dbName").val();
        var recID = $("#recID").val();
        var recTitle = $("#recTitle").val();
        var favid = $("input[name='favcate']:checked").val();
        var saveurl = "@Html.Raw(Url.Action("InsertFavoriteFolder", "UserCenter"))";
        $.ajax({
            type: "POST",
            data: { "favCateID": favid, "dbCode": dbCode, "dbName": dbName, "recid": recID, "recTitle": recTitle },
            url: saveurl,
            success: function (f) {
                if (f == "True") {
                    favClose();
                    var str = "<a onclick=\"canclefav()\" class='btn btn-m btn-prim-f ml10'><i class=\"iconfont icon-star\"></i>取消收藏</a>";
                    $(".favCate").html(str);
                }
                else {
                    messageAlert("操作失败！");
                }
            },
            error: function (e)
            { }
        })
    }
    function canclefav() {
        var saveurl = "@Html.Raw(Url.Action("CancelFavByRecID", "UserCenter"))";
            $.ajax({
                type: "POST",
                data: { "recid": $("#recID").val() },
                url: saveurl,
                success: function (f) {
                    if (f == "True") {
                        var str = " <a onclick=\"showFavCate('" + $("#recTitle").val() + "')\" class='btn btn-m btn-prim-f ml10'><i class=\"iconfont icon-star\"></i>收藏</a>";
                        $(".favCate").html(str);
                    }
                    else {
                        messageAlert("操作失败！");
                    }
                },
                error: function (e)
                { }
            })
        }
</script>
@*收藏列表*@

<input type="hidden" id="isFav" name="isFav" value="@ViewBag.IsFav"/>
<input type="hidden" id="recID" name="recID" value="@ViewBag.recordId" />
<input type="hidden" id="dbCode" name="dbCode" value="@ViewBag.DbName" />
<input type="hidden" id="dbName" name="dbName" value="@ViewBag.DbDispName" />
<input type="hidden" id="recTitle" name="recTitle" value="@ViewBag.recTitle" />
<div class="talkDivBg-message message" style="z-index: 999;">
    <div class="talkDiv talkDivTr talkW-550 form-h message" style="margin-top: -205px; display: none">
        <div class="talkDiv-title" style="padding-top: 10px">
            <h3 class='bbsolid'><i class="blue-block"></i><span>收藏分类</span></h3>
        </div>
        <div class="talkDiv-body talkDiv-body1" id="messageDiv" style="padding: 0px 40px 10px">
            <ul class="ulfield">
            </ul>
        </div>
        <div class="f-gp" style="margin-left: 60px; padding-bottom: 30px; margin-top: 5px">
            <div class="f-ct">
                <button id="btnSubmit" class="btn btn-m btn-prim-f btn-submit" onclick="savefav()">确定</button>
                &nbsp;&nbsp
                    <a href="javascript:void(0);" id="btnClose" class="btn btn-m btn-submit btn-defa-f" onclick="favClose()">取消</a>
            </div>
        </div>
    </div>
</div>
<!--内容==开始-->
<div class="wrap detail-con">
    @{if (ViewBag.Type == (int)CNKI.TPI.Web.Base.MediaType.Pic)
      {
        @RenderPage("Detail_PicInfo.cshtml");
      }
      else if (ViewBag.Type == (int)CNKI.TPI.Web.Base.MediaType.Video)
      {
        @RenderPage("Detail_VideoInfo.cshtml");
      }
      else if (ViewBag.Type == (int)CNKI.TPI.Web.Base.MediaType.Audio)
      {
        @RenderPage("Detail_AudioInfo.cshtml");
      }
      else if (ViewBag.Type == (int)CNKI.TPI.Web.Base.MediaType.Doc)
      {
        @RenderPage("Detail_DocInfo.cshtml");
      }
      else if (ViewBag.Type == (int)CNKI.TPI.Web.Base.MediaType.News)
      {
        @RenderPage("Detail_News.cshtml");
      }
      else
      {
        @RenderPage("Detail_Journal.cshtml");
      }
    }


    <!-- 相似文献 -->
    <div class="xg-search xs-doc">
        @if (ViewBag.Type != (int)CNKI.TPI.Web.Base.MediaType.News)
        {

            string similarString = CNKI.TPI.Web.Base.ColumnAliasHelper.GetContent(ViewBag.DetialField, ViewBag.DbName, 0, "SYS_FLD_VSM");
            //Html.RenderAction("DataList", "SimilarDoc", new { dbId = ViewBag.dbId, recordId = ViewBag.recordId, similarWord = similarString, type = ViewBag.Type });
            //Html.RenderAction("PicList", "SimilarDoc", new { dbId = ViewBag.dbId, recordId = ViewBag.recordId, similarWord = ViewBag.DetialField.Rows[0]["SYS_FLD_VSM"], type = ViewBag.Type });
            var ajaxOptions = new AjaxOptions()
                     {
                         HttpMethod = "post",
                         UpdateTargetId = "similarinfo",
                         InsertionMode = InsertionMode.Replace
                     };
                        
            @Ajax.ActionLink("隐藏域", "DataList", new { dbId = ViewBag.dbId, recordId = ViewBag.recordId, similarWord = similarString, type = ViewBag.Type, dbCode = ViewBag.DbName, topicCode = ViewBag.TopicCode },
                        ajaxOptions, new { id = "UpdateSmiLink", hidden = "hidden", style = "display:none" })

            <div id="similarinfo">
                <img src="~/Images/loading.gif" width="50" />
            </div>
        }
    </div>

</div>
<!--内容==结束-->

